{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}
<style>
	.layui-td-gray{width: 100px}
</style>
<form class="layui-form p-4">
	<h3 class="pb-3">平台配置</h3>
	<table class="layui-table layui-table-form">
		<input type="hidden" name="id" value="{$id}">
		<tr>
			<td class="layui-td-gray">版本号</td>
			<td>
				<input type="text" name="ban" lay-verify="required" autocomplete="off" placeholder="请输入版本号"
					   lay-reqText="请输入版本号" class="layui-input" {notempty name="$config.ban" }
					   value="{$config.ban}" {/notempty} style="display: inline-block;">
			</td>
		</tr>
		<tr>
			<td class="layui-td-gray">登录页背景图</td>
			<td>
				<div class="layui-upload">
					<button type="button" class="layui-btn layui-btn-sm" id="upload_btn_thumb1">上传图片</button>
					<div class="layui-upload-list" id="upload_box_thumb1">
						<img src="{$config.bg_img_login|default=''}" width="100" style="width:150px;max-width:150px" />
						<input type="hidden" name="bg_img_login" value="{$config.bg_img_login|default=''}" lay-verify="required">
					</div>
				</div>
			</td>
		</tr>
		<tr>
			<td class="layui-td-gray">首页背景图</td>
			<td>
				<div class="layui-upload">
					<button type="button" class="layui-btn layui-btn-sm" id="upload_btn_thumbs">上传图片</button>
					<div class="layui-upload-list" id="upload_box_thumbs">
						<img src="{$config.bg_img_one|default=''}" width="100" style="width:150px;max-width:150px" />
						<input type="hidden" name="bg_img_one" value="{$config.bg_img_one|default=''}" lay-verify="required">
					</div>
				</div>
			</td>
		</tr>
		<tr>
			<td class="layui-td-gray">SVIP定制背景图</td>
			<td>
				<div class="layui-upload">
					<button type="button" class="layui-btn layui-btn-sm" id="upload_btn_thumbss">上传图片</button>
					<div class="layui-upload-list" id="upload_box_thumbss">
						<img src="{$config.bg_img_two|default=''}" width="100" style="width:150px;max-width:150px" />
						<input type="hidden" name="bg_img_two" value="{$config.bg_img_two|default=''}" lay-verify="required">
					</div>
				</div>
			</td>
		</tr>
		<tr>
			<td class="layui-td-gray-3">教程</td>
			<td>
				<div class="layui-upload">
					<button type="button" class="layui-btn layui-btn-sm" id="upload_btn_thumb">上传视频</button>
					<div class="layui-upload-list" id="upload_box_thumb">
						<video src="{$config.video|default=''}" width="200" style="width:300px;max-width:300px;" controls />
						<input type="hidden" name="video" value="{$config.video|default=''}" lay-verify="required" lay-reqText="请上传视频">
					</div>
				</div>
			</td>
		</tr>
<!--		<tr>-->
<!--			<td class="layui-td-gray">首页中部标题</td>-->
<!--			<td>-->
<!--				<input type="text" name="index_title" lay-verify="required" autocomplete="off" placeholder="请输入首页中部标题"-->
<!--					   lay-reqText="请输入首页中部标题" class="layui-input" {notempty name="$config.index_title" }-->
<!--					   value="{$config.index_title}" {/notempty} style="display: inline-block;">-->
<!--			</td>-->
<!--		</tr>-->

	</table>

	<div class="py-3">
		<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
		<button type="reset" class="layui-btn layui-btn-primary">重置</button>
	</div>
</form>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script>
	const moduleInit = ['tool','tinymce'];
	function gouguInit() {
		var form = layui.form, tool = layui.tool;
		var edit = layui.tinymce.render({
			selector: '#container_content',
			height: 500
		});
		var upload_thumbs11 = layui.upload.render({
			elem: '#upload_btn_thumb1',
			url: '/admin/api/upload',
			done: function (res) {
				//如果上传失败
				if (res.code == 1) {
					return layer.msg('上传失败');
				}
				//上传成功
				$('#upload_box_thumb1 input').attr('value', res.data.filepath);
				$('#upload_box_thumb1 img').attr('src', res.data.filepath);
			}
		});
		var upload_thumbs = layui.upload.render({
			elem: '#upload_btn_thumb',
			accept:'video',
			url: '/admin/api/upload',
			done: function (res) {
				//如果上传失败
				if (res.code == 1) {
					return layer.msg('上传失败');
				}
				//上传成功
				$('#upload_box_thumb input').attr('value', res.data.filepath);
				$('#upload_box_thumb video').attr('src', res.data.filepath);
			}
		});
		var upload_thumbs = layui.upload.render({
			elem: '#upload_btn_thumbs',
			url: '/admin/api/upload',
			done: function (res) {
				//如果上传失败
				if (res.code == 1) {
					return layer.msg('上传失败');
				}
				//上传成功
				$('#upload_box_thumbs input').attr('value', res.data.filepath);
				$('#upload_box_thumbs img').attr('src', res.data.filepath);
			}
		});
		var upload_thumbss = layui.upload.render({
			elem: '#upload_btn_thumbss',
			url: '/admin/api/upload',
			done: function (res) {
				//如果上传失败
				if (res.code == 1) {
					return layer.msg('上传失败');
				}
				//上传成功
				$('#upload_box_thumbss input').attr('value', res.data.filepath);
				$('#upload_box_thumbss img').attr('src', res.data.filepath);
			}
		});

		//监听提交
		form.on('submit(webform)', function (data) {
			let callback = function (e) {
				layer.msg(e.msg);
				if (e.code == 0) {
					parent.layui.tool.close(1000);
				}
			}
			tool.post("/admin/conf/edit", data.field, callback);
			return false;
		});
	}
</script>
{/block}
<!-- /脚本 -->